package main

import (
	"jinquan.supor.com/common"
	"jinquan.supor.com/samples/mongo/docs"
	"strings";"fmt"
)

func PrintValues(i interface{}, k1 string, k2 string) {
	m := common.If2Map(i)	
	kk1 := strings.ToLower(k1); kk2 := strings.ToLower(k2) 
	fmt.Printf("%s: %s\t%s: %s\n", kk1, m[kk1], kk2, m[kk2])
}

func main() {
	//Pod 内部域名
	/*
	clnt, _ := common.Mongo_ServerConn(`mongodb://mongo-0.mongo.mongo-ns.svc.cluster.local:27017,
											      mongo-1.mongo.mongo-ns.svc.cluster.local:27017,
												  mongo-2.mongo.mongo-ns.svc.cluster.local:27017/?slaveOk=true`, 
												  "secondary")
	*/
	clnt, _ := common.Mongo_ServerConn(`mongodb://mongodb.jinquan.svc.cluster.local:27017`, "primary")
	
	var docArr = testdoc.GenData01DocArray(2)
	common.Mongo_CollAddDocs(clnt, "db_5", "coll_1", docArr)

	k1 := "Name";v1 := common.IfVal_string(docArr[0], k1)
	k2 := "FloatVal";v2 := common.IfVal_float32(docArr[0], k2)

	objZ := common.F1S1KV{ 
		Ks: k1, 
		Vs: v1,
		Kf: k2,
		Vf: v2,
	}
	var docSt_X = testdoc.AllocData01Doc()
	docSt_X[0],_ = objZ.Doc(clnt, "db_5", "coll_1", docSt_X[0]); fmt.Printf("Original Document ->> %v\n", docArr[0])

	/* 删除Document */
	objZ.DocDel(clnt, "db_5", "coll_1", docSt_X[0]);

	docSt_X[0],_ = objZ.Doc(clnt, "db_5", "coll_1", docSt_X[0]); 

}